package pkg

import (
	"github.com/gin-gonic/gin"
	"github.com/google/uuid"
	"path/filepath"
)

func AliyunFileUpload(c *gin.Context) (string, error) {
	file, _ := c.FormFile("file")
	ext := filepath.Ext(file.Filename)

	// uploads/20230501/1234567890.png
	filePath := "uploads/" + uuid.NewString() + ext
	err := c.SaveUploadedFile(file, "./"+filePath)
	if err != nil {
		return "", err
	}

	// 上传到阿里云OSS
	err = UploadToAliyunOSS(filePath)
	if err != nil {
		return "", err
	}

	return filePath, nil
}

func UploadToAliyunOSS(filePath string) error {
	// 上传到阿里云OSS
	// ...
	return nil
}
